#!/bin/bash
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/Cent* /etc/yum.repos.d/bak

mount /dev/cdrom /mnt
cat > /etc/yum.repos.d/local.repo << EOF
[centos]
name=centos
baseurl=file:///mnt/
gpgcheck=0
enabled=1
EOF

yum clean all
yum repolist all
sleep 5

systemctl stop firewalld
setenforce 0

yum install -y net-tools

yum install  -y bind-chroot bind-utils

cd /var/named/chroot/etc

systemctl start named-chroot

cp -p named.conf named.conf.bak



echo '// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };
        forwarders      {8.8.8.8;};
        recursion yes;

        dnssec-enable no;
        dnssec-validation no;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";
        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "." IN {
        type hint;
        file "named.ca";
};
zone "wylsales.cn"  {
        type master;
        file "wylsales.cn.zone";
};
zone "wylpromote.com"  {
        type master;
        file "wylpromote.com.zone";
};
zone "wyl.com" {
        type master;
        file "wyl.com.zone";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key"; ' > named.conf

named-checkconf

cd /var/named/chroot/var/named/

echo '$TTL 1D
$ORIGIN wylsales.cn.
@       IN SOA  wylsales.cn. admin.wylsales.cn. (
                                        5000    ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   ns1.wylsales.cn.
ns1     IN A    192.168.23.10
www     IN A    192.168.23.11
' >>wylsales.cn.zone

named-checkzone wylsales.cn wylsales.cn.zone

echo '$TTL 1D
$ORIGIN wylpromote.com.
@       IN SOA  wylpromote.com. admin.wylpromote.com. (
                                        5001    ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   ns1.wylpromote.com.
ns1     IN A    192.168.23.10
www     IN A    192.168.23.11
' >>wylpromote.com.zone

named-checkzone wylpromote.com wylpromote.com.zone

echo '$TTL 1D
$ORIGIN wyl.com.
@       IN SOA  wyl.com. admin.wyl.com. (
                                        5000    ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   ns1.wyl.com.
ns1     IN A    192.168.23.10
haha     IN A    192.168.23.11
' >>wyl.com.zone

named-checkzone wyl.com wyl.com.zone



echo 'nameserver 192.168.23.10' >/etc/resolv.conf

systemctl restart named-chroot



